using System;
using System.ComponentModel;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
	[DataObject(true)]
    public partial class EventLogController
    {
	
		public SqlDataProvider DataProvider { get; set; }

        public EventLogController()
        {
            DataProvider = new SqlDataProvider();
        }
	
		[DataObjectMethod(DataObjectMethodType.Insert, true)]
        public Guid InsertEventLog(EventLogInfo oi)
		{
            return DataProvider.InsertEventLog(oi.PhoneId, oi.UserId, oi.MacAddress, oi.IpAddress, oi.UserAgent, oi.EventSource, oi.EventMessage, oi.EventType, oi.EventDate);
		}

		[DataObjectMethod(DataObjectMethodType.Update, true)]
        public int UpdateEventLog(EventLogInfo oi) 
		{
			return DataProvider.UpdateEventLog(oi.EventLogId, oi.PhoneId, oi.UserId, oi.MacAddress, oi.IpAddress, oi.UserAgent, oi.EventSource, oi.EventMessage, oi.EventType, oi.EventDate);
		}
		
		[DataObjectMethod(DataObjectMethodType.Delete, true)]
        public int DeleteEventLog(Guid eventLogId)
		{
			return DataProvider.DeleteEventLog(eventLogId);
        }

		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public EventLogInfo SelectEventLog(Guid eventLogId)
        {    
			return ObjectFromDataRow(DataProvider.SelectEventLog(eventLogId));
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<EventLogInfo> SelectEventLogs()
		{
            return ListFromDataTable(DataProvider.SelectEventLogs());
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<EventLogInfo> SelectEventLogs(string sortExpression)
        {
            List<EventLogInfo> retList = SelectEventLogs();
            if (sortExpression.Length > 0)
            {
                retList.Sort(new EventLogComparer(sortExpression));
            }
            return retList;
        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
		public List<EventLogInfo> SelectEventLogsByUser(Guid userId)
		{
			return ListFromDataTable(DataProvider.SelectEventLogsByUser(userId));
		}
		
        public List<EventLogInfo> SelectEventLogsByUser(Guid userId,string sortExpression)
		{
			List<EventLogInfo> retList = SelectEventLogsByUser(userId);
            if (sortExpression.Length > 0)
            {
                retList.Sort(new EventLogComparer(sortExpression));
            }
            return retList;
		}

	}

}
		